
setcolor("w/n")

cls

falahora(10,10,"Aperte qualquer tecla . . . ",,.t.)
setcolor("w/n")
cls

function falahora(lin,col,mensa,logi,duplo)

Public a, x:=len(mensa)

set cursor off

if logi=nil
   logi=.t.
endif

if duplo=nil
   duplo=.f.
endif

if x <= 8
   x:=8
endif

do while .t.
   if logi
      if duplo
         @ lin-1,col-1 to lin+2,col+x double
         @ lin+1,col say mensa
      else
         @ lin-1,col-1 to lin+2,col+x
         @ lin+1,col say mensa
      endif
   endif

   @ lin,col say time()
   a:=inkey(.01)

   if a <> 0
      set cursor on
      return(a)
   endif
   loop
enddo

function horaampm(tempo)

hora=val(left(tempo,2))
minuto=substr(tempo,4,2)

do case
   case hora >= 12
   hora=hora-12
   sinal=" pm"
   case hora < 12
   sinal=" am"
endcase

hora=str(hora,2)
final=hora+":"+minuto+sinal

return(final)

function dizhora(lin,col)

if lin=nil
   lin=0
endif

if col=nil
   col=70
endif

if lin > maxrow() .or. col > maxcol()
   tone(250,1)
   return(.F.)
endif

@ lin,col say left(time(),5)
return nil

function segundos(tempo,inicio)

if inicio <> nil

   horas=val(left(tempo,2))-val(left(inicio,2))
   minutos=val(subs(tempo,4,2))-val(subs(inicio,4,2))
   s1=val(subs(tempo,7,2))
   s2=val(subs(inicio,7,2))

   if s2 <= s1
     segs=s1-s2
   else
     segs=s1+(60-s2)
   endif

   tempo=stuff(tempo,1,2,str(horas,2))
   tempo=stuff(tempo,4,2,str(minutos,2))
   tempo=stuff(tempo,7,2,str(segs,2))

endif

final=val(left(tempo,2))*3600+val(subs(tempo,4,2))*60+VAL(SUBSTR(tempo,7,2))

return(final)

function diftempo(hora1,hora2)
totsegdia=86400

hora1=segundos(hora1)
hora2=segundos(hora2)

if hora2 < hora1
   hora2=hora2+totsegdia
endif

final=hora2-hora1
final=str(int(mod(final/3600,24)),2,0)+":"+str(int(mod(final/60,60)),2,0)+":"+;
      str(int(mod(final,60)),2,0)

if left(final,1)=" "
   final=stuff(final,1,1,"0")
endif

if subs(final,4,1)=" "
   final=stuff(final,4,1,"0")
endif

if subs(final,7,1)=" "
   final=STUFF(final,7,1,"0")
endif

return(final)
